package pos.data;

import java.sql.*;

import pos.domain.*;
import pos.utils.*;

public class JDBCUserRatingDAO implements IUserRatingDAO {

 
    public void insertUserRating(Connection conn, UserRating ur) {
        PreparedStatement stmt=null;
        String OID = UIDGenerator.getInstance().getKey();//generamos la clave primaria de la clase
        String sql ="INSERT INTO UserRating (userRatOID,email,calificationRating,comments) VALUES (?, ?, ?, ?) ";
        try{
            stmt=conn.prepareStatement(sql);
            
            stmt.setString(1, OID);
            stmt.setString(2, ur.getEmail());
            stmt.setFloat(3, ur.getCalification());
            stmt.setString(4, ur.getComments());
            
            stmt.executeUpdate();
        }catch (SQLException e) {
            System.out.println("Message: " + e.getMessage());
            System.out.println("SQLState: " + e.getSQLState());
            System.out.println("ErrorCode: " + e.getErrorCode());
        } finally {
            
            try {
                if (stmt != null) {
                    stmt.close();
                }
            } catch (SQLException e) {

            }
        }

    }



    }


